//
//  MHComment.m
// MiaoCircle
//
//Created by acgera on 2018/4/9.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHComment.h"

@implementation MHComment
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"createdAt"        : @"created",
//             @"momentIdstr"      : @"",
             @"idstr"            : @"commentId",
             @"text"             : @"commentTxt",
             

//             @"toUser"           : @"to_user",
//             @"fromUser"         : @"from_user"
             };
}

-(MHUser *)fromUser
{
    if (!_fromUser) {
        _fromUser = [MHUser new];
        _fromUser.screenName = self.commentUserName?:@"";
        _fromUser.userId = self.commentUserId;
        _fromUser.idstr = [NSString stringWithFormat:@"%ld",(long)self.commentUserId];
        _fromUser.profileImageUrl = [NSURL URLWithString:self.commentUserHeadPic];
    }
    return _fromUser;
}

- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
    self.createdAt = [self.createdAt dateByAddingHours:-8];
    return YES;
}

-(MHUser *)toUser
{
    if (!self.isReply) {
        return nil;
    }
    
    if (!_toUser) {
        _toUser = [MHUser new];
        _toUser.screenName = self.replyUserName?:@"";
    }
    return _toUser;
}
@end
